// 定义用户角色枚举
const UserRole = {
  SUPER_ADMIN: 0,
  DEVICE_INSTALLER: 6,
  DEVICE_INSPECTOR: 5
}

// 定义操作类型和对应的处理函数
const actions = {
  SUPER_ADMIN: {
    TYPE_0: () => {
      // 如果是待安装
    },
    TYPE_1: () => {
      // 如果是已安装
    },
    PATROL_1: () => {
      // 如果是待巡检
    },
    PATROL_2: () => {
      // 如果是已巡检
    }
  },
  DEVICE_INSTALLER: {
    TAB_0: () => {
      // 未安装
    },
    TAB_1: () => {
      // 已安装
    }
  },
  DEVICE_INSPECTOR: {
    TAB_0: () => {
      // 未巡检
    },
    TAB_1: () => {
      // 已巡检
    }
  }
}

// 获取当前用户角色
const currentUserRole = getUserRole(userStore.userInfo.authorize)

// 根据用户角色和查询参数执行相应的操作
switch (currentUserRole) {
  case UserRole.SUPER_ADMIN:
    if (query.value.type === 0) {
      actions.SUPER_ADMIN.TYPE_0()
    } else if (query.value.type === 1) {
      actions.SUPER_ADMIN.TYPE_1()
    }
    if (query.value.patrol_state === 1) {
      actions.SUPER_ADMIN.PATROL_1()
    } else if (query.value.patrol_state === 2) {
      actions.SUPER_ADMIN.PATROL_2()
    }
    break

  case UserRole.DEVICE_INSTALLER:
    if (tabCurrent.value === 0) {
      actions.DEVICE_INSTALLER.TAB_0()
    } else if (tabCurrent.value === 1) {
      actions.DEVICE_INSTALLER.TAB_1()
    }
    break

  case UserRole.DEVICE_INSPECTOR:
    if (tabCurrent.value === 0) {
      actions.DEVICE_INSPECTOR.TAB_0()
    } else if (tabCurrent.value === 1) {
      actions.DEVICE_INSPECTOR.TAB_1()
    }
    break

  default:
    // 处理未知角色或其他情况
    break
}

// 获取用户角色的辅助函数
function getUserRole(authorize) {
  switch (authorize) {
    case 0:
    case 1:
      return UserRole.SUPER_ADMIN
    case 6:
      return UserRole.DEVICE_INSTALLER
    case 5:
      return UserRole.DEVICE_INSPECTOR
    default:
      return null // 或抛出异常等，视具体情况而定
  }
}
